//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package gitlab_triger

import (
	"fmt"
	"testing"
)

const _NOTE_HOOK_DATA = `
{
    "object_kind": "note",
    "event_type": "note",
    "user": {
        "id": 1,
        "name": "Administrator",
        "username": "root",
        "avatar_url": "https://www.gravatar.com/avatar/b4b328dfb4d8a2743e6cb237b1b82b478b11a7e317528d9e8ebb1a1d6355c4a9?s=80&d=identicon",
        "email": "[REDACTED]"
    },
    "project_id": 1,
    "project": {
        "id": 1,
        "name": "test·",
        "description": null,
        "web_url": "http://09b00b609eb5/g1/test",
        "avatar_url": null,
        "git_ssh_url": "git@09b00b609eb5:g1/test.git",
        "git_http_url": "http://09b00b609eb5/g1/test.git",
        "namespace": "g1",
        "visibility_level": 0,
        "path_with_namespace": "g1/test",
        "default_branch": "master",
        "ci_config_path": null,
        "homepage": "http://09b00b609eb5/g1/test",
        "url": "git@09b00b609eb5:g1/test.git",
        "ssh_url": "git@09b00b609eb5:g1/test.git",
        "http_url": "http://09b00b609eb5/g1/test.git"
    },
    "object_attributes": {
        "attachment": null,
        "author_id": 1,
        "change_position": null,
        "commit_id": null,
        "created_at": "2025-02-12 07:44:06 UTC",
        "discussion_id": "1523a520892983f750ee4db6c01f5bae6a32d2f6",
        "id": 1,
        "line_code": null,
        "note": "1111111",
        "noteable_id": 1,
        "noteable_type": "Issue",
        "original_position": null,
        "position": null,
        "project_id": 1,
        "resolved_at": null,
        "resolved_by_id": null,
        "resolved_by_push": null,
        "st_diff": null,
        "system": false,
        "type": null,
        "updated_at": "2025-02-12 07:44:06 UTC",
        "updated_by_id": null,
        "description": "1111111",
        "url": "http://09b00b609eb5/g1/test/-/issues/1#note_1",
        "action": "create"
    },
    "repository": {
        "name": "test·",
        "url": "git@09b00b609eb5:g1/test.git",
        "description": null,
        "homepage": "http://09b00b609eb5/g1/test"
    },
    "issue": {
        "author_id": 1,
        "closed_at": null,
        "confidential": false,
        "created_at": "2025-02-12 07:33:28 UTC",
        "description": "xxxxx",
        "discussion_locked": null,
        "due_date": null,
        "id": 1,
        "iid": 1,
        "last_edited_at": null,
        "last_edited_by_id": null,
        "milestone_id": null,
        "moved_to_id": null,
        "duplicated_to_id": null,
        "project_id": 1,
        "relative_position": 513,
        "state_id": 1,
        "time_estimate": 0,
        "title": "xxxx",
        "updated_at": "2025-02-12 07:44:06 UTC",
        "updated_by_id": null,
        "type": "Issue",
        "url": "http://09b00b609eb5/g1/test/-/issues/1",
        "total_time_spent": 0,
        "time_change": 0,
        "human_total_time_spent": null,
        "human_time_change": null,
        "human_time_estimate": null,
        "assignee_ids": [],
        "assignee_id": null,
        "labels": [],
        "state": "opened",
        "severity": "unknown",
        "customer_relations_contacts": []
    }
}
`

func TestExtractNoteHookAttr(t *testing.T) {
	attrList, err := ExtractNoteHookAttr([]byte(_NOTE_HOOK_DATA))
	if err != nil {
		t.Fatal(err)
		t.FailNow()
	}
	fmt.Println(attrList)
}
